//
//  AXHdzqHomeFirstCollectionCell.m
//  AnXin100
//
//  Created by 天质弘耕 on 2018/10/30.
//  Copyright © 2018 tzhg. All rights reserved.
//

#import "AXHdzqHomeFirstCollectionCell.h"
#import "UIView+SDAutoLayout.h"
#import "ZXCategories.h"

@implementation AXHdzqHomeFirstCollectionCell

- (id)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        [self creatView];
        [self setlayout];
        
        
    }
    return self;
}

- (void)creatView {
    
    self.bgImg = [[UIImageView alloc]init];
    self.bgImg.userInteractionEnabled = YES;
    self.bgImg.image = [UIImage imageNamed:@"hdzqBg"];
    [self.contentView addSubview:self.bgImg];
    
    
    /** imageview */
    self.storeImageView = [[UIImageView alloc]init];
    self.storeImageView.image = [UIImage imageNamed:@"pt"];
    self.storeImageView.contentMode =UIViewContentModeScaleToFill;
    self.storeImageView.clipsToBounds = YES;
    [self.bgImg addSubview:self.storeImageView];
    /** 预售按钮 */
    self.activeBtn = [[UIButton alloc]init];
    [self.activeBtn addTarget:self action:@selector(tapBtn:) forControlEvents:UIControlEventTouchUpInside];
    self.activeBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.activeBtn.cornerRadius = 2;
    self.activeBtn.titleLabel.font = FONT_FOURTEEN;
    [self.activeBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    self.activeBtn.backgroundColor = COLOR_ORG;
    [self.bgImg addSubview:self.activeBtn];
    
    /** title */
    self.storeNameLabel = [[UILabel alloc]init];
    self.storeNameLabel.backgroundColor = [UIColor whiteColor];
    self.storeNameLabel.font = FONT_TWELVE;
    self.storeNameLabel.text = @"云南夏黑葡萄 新鲜无籽提 子水果";
    self.storeNameLabel.textColor = COLOR_DIV;
    self.storeNameLabel.textAlignment = NSTextAlignmentCenter;
    [self.bgImg  addSubview:self.storeNameLabel];
    /** 价格 */
    self.priceLabel = [[UILabel alloc]init];
    self.priceLabel.backgroundColor = [UIColor whiteColor];
    self.priceLabel.textAlignment = NSTextAlignmentRight;
    self.priceLabel.font = FONT_TWELVE;
    self.priceLabel.textColor = COLOR_ORG;
    self.priceLabel.text = @"¥44/kg   ";
    [self.bgImg  addSubview:self.priceLabel];
    
    
    
    
}

- (void)setlayout {
    
     float w = (Wi-30)/2;
    
    self.bgImg.sd_layout
    .leftSpaceToView(self.contentView,0)
    .topSpaceToView(self.contentView,0)
    .rightSpaceToView(self.contentView, 0)
    .heightIs(w);
    
   
    /** 店铺图片 */
    self.storeImageView.sd_layout
    .leftSpaceToView(self.bgImg,30)
    .topSpaceToView(self.bgImg,15)
    .rightSpaceToView(self.bgImg, 30)
    .heightIs(w-90);
    
    /** 预售按钮 */
    self.activeBtn.sd_layout
    .leftSpaceToView(self.bgImg, 10)
    .topSpaceToView(self.bgImg, 10)
    .widthIs(60)
    .heightIs(20);
    
    

    
    /** 店铺名字 */
    self.storeNameLabel.sd_layout
    .leftEqualToView(self.storeImageView)
    .topSpaceToView(self.storeImageView,0)
    .widthRatioToView(self.storeImageView, 1)
    .autoHeightRatio(0)
    .minHeightIs(40);
    
    /** 价格 */
    self.priceLabel.sd_layout
    .leftEqualToView(self.storeImageView)
    .topSpaceToView(self.storeNameLabel, 0)
    .widthRatioToView(self.storeImageView, 1)
    .heightIs(20);
    
    
    
    
    
    
    
}

#pragma mark - axtion

- (void)tapBtn:(UIButton *)btn {
  
    
    if (self.tapButtonClickedBlock) {
        
    
        
        self.tapButtonClickedBlock(btn.tag);
    }
    
}

- (void)tapPraise:(UIButton *)btn {
    
}

@end
